#!/bin/bash
# pnpm 配置验证脚本

echo "🔍 验证 pnpm 配置..."

# 检查 pnpm 版本
echo "📦 pnpm 版本:"
pnpm --version

# 检查 package.json 中的 packageManager 字段
echo -e "\n📋 packageManager 配置:"
node -e "const pkg = require('./package.json'); console.log(pkg.packageManager || '未配置');"

# 检查 engines 字段
echo -e "\n⚙️  engines 配置:"
node -e "const pkg = require('./package.json'); console.log(JSON.stringify(pkg.engines, null, 2));"

# 检查 .npmrc 文件
echo -e "\n📁 .npmrc 配置:"
if [ -f ".npmrc" ]; then
    cat .npmrc
else
    echo "❌ .npmrc 文件不存在"
fi

# 检查 pnpm-lock.yaml
echo -e "\n🔒 锁定文件:"
if [ -f "pnpm-lock.yaml" ]; then
    echo "✅ pnpm-lock.yaml 存在"
    head -n 5 pnpm-lock.yaml
else
    echo "❌ pnpm-lock.yaml 不存在"
fi

# 显示可用脚本
echo -e "\n🚀 可用脚本:"
node -e "const pkg = require('./package.json'); Object.keys(pkg.scripts).forEach(script => console.log(\`  pnpm \${script}\`));"

echo -e "\n✅ pnpm 配置验证完成!"